package com.ruoyi.project.system.lotto.domain;


import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author wiggins
 */
@Data
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class ResObject<T> implements Serializable {

	private static final long serialVersionUID = -3007164184721455683L;
	private String code;
	private String msg;
	private Object data;
	private List<T> resList;

	public ResObject(String code, String msg, Object data, List<T> resList){
		this.code = code;
		this.msg = msg;
		this.data = data;
		this.resList = resList;
	}

	public ResObject(String resCode, String msg){
		this.code = resCode;
		this.msg = msg;
	}

	public ResObject(String code, String msg, Object data){
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

    public ResObject() {}

	public static ResObject error(String msg){
		return new ResObject(Constant.ERROR,msg);
	}

	public static ResObject error(String msg, Object data){
		return new ResObject(Constant.ERROR,msg,data);
	}

	public static ResObject error(String code,String msg){
		return new ResObject(code,msg);
	}

	public static ResObject success(String msg){
		return new ResObject(Constant.SUCCESS,msg);
	}

	public static ResObject success(String resMessage, Object data){
		return new ResObject(Constant.SUCCESS,resMessage,data);
	}

	public static ResObject success() {
		return success("调用成功");
	}
}
